<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    li{
      height: 50px;
      background-color: #fc8;
      margin-top:5px;
    }
  </style>
</head>
<body>
  <div id="app">
    <button @click="changeLength">改变length</button>
    <ul>
      <li v-for="(item,index) in arr" 
        @click="changeLi(index)"
        :key="index">
        {{item}}
      </li>
    </ul>
  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#app',
      data: {
        arr: ['a','b','c','d']
      },
      methods: {
        changeLength(){
          // this.arr.length = 2;
          // this.$set(this.arr, 'length' , 2)
          console.log(this.arr);
        },
        changeLi(index){
          // this.arr[index] = 0;
          this.$set(this.arr,index,0);
          console.log(this.arr);
        }
      }
    })
  </script>
</body>
</html>